<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page language="java" import="java.lang.*" %>
<%@ page import = "java.sql.SQLException" %>
<%@ page import = "com.seniorproject.aims.*" %>
<%@ page import = "java.util.List" %>
<%@page import="java.util.ArrayList"%>
<%@ page import = "java.util.Properties" %>
<%@ page import = "javax.servlet.ServletContext" %>
<%@ page import = "java.io.File" %>
<%@ page import = "java.io.InputStream" %>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Home</title>
	
	<link rel="stylesheet" type="text/css" href="css/stylev2.css" />
	<link rel="stylesheet" type="text/css" href="css/menubar.css" />
	<link rel="stylesheet" type="text/css" href="css/frame.css" />
	
	<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
	
	<style type="text/css">
		a {
	      text-decoration:none;
	   }
	</style>
	
	<script type="text/javascript">		
		function search_name(name) {	
			if($('#namelist').find('option').length > 0) {
				
				$('#namelist').find('option').remove();
			}
			if(name != "") {
				/* AJAX */
				var xmlhttp;
				
				if(window.XMLHttpRequest) {
					// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
				else {
					// code for IE6, IE5
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				xmlhttp.onreadystatechange = function() {
					if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
						
						
						var jsonObj = JSON.parse(xmlhttp.responseText);
						
						if(jsonObj.length == 0) {
							// no data
						}
						else{
							for(i in jsonObj) {
								var text = jsonObj[i].nameTH+"  "+jsonObj[i].surnameTH;
								var option = '<option value="'+text+'" >';
								
								$('#namelist').append(option);
							}
						}
					}
				}
				
				xmlhttp.open("POST", "admin_search_name.jsp?name="+name, true);
				xmlhttp.send();
			}			
		}
	</script>
	
</head>
<body>
<%
	String strUser = String.valueOf(session.getAttribute("sUser"));
	HttpSession htp_session = request.getSession();
			
	// check session
		if (htp_session == null || htp_session.getAttribute("sUser") == null) {
		    // Forward the control to login.jsp if authentication fails or session expires
		    request.getRequestDispatcher("/login.jsp").forward(request,
		        response);
		}
		if(!"admin".equals(htp_session.getAttribute("sUser"))){%>
			<script>alert("This user dont have PERMISSION to access this zone.");</script>
			<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=system_select.jsp"> 	
	<%}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////

		String name = String.valueOf(session.getAttribute("name"));
		String surname = String.valueOf(session.getAttribute("surname"));
		String role_name = String.valueOf(session.getAttribute("curriculum_role"));
		
		String department_id = String.valueOf(session.getAttribute("department_id"));
		
		System.out.println("name : " + name);///////////////////////////////
		System.out.println("department_id : " + department_id);/////////////////////////
		
		List<String> system_name = new ArrayList<String>();
		
		Permission permission = new Permission(strUser,name);
		permission.setCurriculumCreate(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_create"))));
		permission.setCurriculumDelete(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_delete"))));
		permission.setCurriculumRead(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_read"))));
		permission.setCurriculumUpdate(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_update"))));
		
		String permiss = "";
		if(permission.getCurriculumCreate()) {
			permiss = permiss + "Add";
		}
		if(permission.getCurriculumUpdate()) {
			if("".equals(permiss)) {
				permiss = permiss + "Edit";
			} else {
				permiss = permiss + " Edit";
			}
		}
		if(permission.getCurriculumRead()) {
			if("".equals(permiss)) {
				permiss = permiss + "Read";
			} else {
				permiss = permiss + " Read";
			}
		}
		if(permission.getCurriculumDelete()) {
			if("".equals(permiss)) {
				permiss = permiss + "Delete";
			} else {
				permiss = permiss + " Delete";
			}
		}

///////////////////////////////////////////////////////////////////////////////////////////////////////////		

%>

    <div id="page-wrap">
		<div id="inside">
			<table border="0">
				<tr style="font-size:24px">
					<td width="600" height="100" style= "background-color: #273b80;border: 0px ;padding: 0px; 0px;" >
						<div id="header_banner-2"></div>
					</td>
					
					<td width="680" height="100" style= "background-color: #273b80;border: 0px;padding: 0px; 0px;" >
						<p align="right"><label><font size="4" color="#ffffff">username : <%=strUser %> &nbsp;&nbsp;</font></label></p>	
						<a href="logout.jsp"><p align="right"><label style="cursor: pointer;"><font size="3" color="#ffffff">log out &nbsp;</font></label></p></a>
					</td>
				</tr>
			</table>
			
			 <ul id="drop-nav">
		        <li style="background-color: #FFFFFF; padding-top: 13px; text-align: center;  border-bottom-color: #FFFFFF; border-left-color: #FFFFFF; border-right-color: #FFFFFF">
		        	<font color="#273b80" size="4.8px" face="Tahoma">หน้าแรก</font>
		        </li>
		        
		        <li>
		            <a href="">องค์กร &nbsp; &#9662;</a>
		            <ul>
		                <li><a href="admin_department.jsp">ภาควิชา</a></li>
		                <li><a href="admin_workgroup.jsp">หน่วยงาน</a></li>
		            </ul>
		        </li>
		        <li><a href="admin_role.jsp">หน้าที่</a></li>
		        <li><a href="admin_account.jsp">บัญชีผู้ใช้</a></li>
		        <li>
		        	<a href="">บุคคล &nbsp; &#9662;</a>
		        	<ul>
		                <li><a href="admin_lecturer.jsp">อาจารย์</a></li>
		                <li><a href="admin_employee.jsp">บุคลากร</a></li>
		            </ul>
		        </li>
		        <li><a href="admin_entrance.jsp">ระบบเข้าศึกษา</a></li>
		        <li><a href="admin_status.jsp">สถานะของนักศึกษา</a></li>
		        <li>
		        	<a href="">ตำแหน่ง &nbsp; &#9662;</a>
		        	<ul>
		                <li><a href="admin_educate_position.jsp">ตำแหน่งทางวิชาการ</a></li>
		                <li><a href="admin_management_position.jsp">ตำแหน่งบริหาร</a></li>
		            </ul>
		        </li>
		    </ul>
				
				<div id="main-content-ac">
					
					<br><br><br><br><br>
						<h2 style="padding-left: 2.5cm; color: #273b80; font-size: 24px;">ยินดีต้อนรับ : ADMIN </h2>
					<br><br>
						<center>	
								<table id="detail_table" width="1000" border="1">
						        	<tr style="font-size:24px" >
						        		<td  width="50" height="50" rowspan="4" style="text-align: center;">
						        			<img id="user_image" src="image/user_no_photo.jpg" style="width:130px;height:160px;	">
						        		</td>
						             	<td  width="500" >
						                	<font size="5"><strong>ชื่อ</strong></font>
						                </td>
						                <td width="400" height="50">
						                	ADMIN
						                </td>
						            </tr>
						                
						                
									<tr style="font-size:24px">
						                <td height="50">
						                	<font size="5"><strong>ตำแหน่ง</strong></font>
						                </td>
						                <td height="50">
						                	ADMIN
						                </td>
						            </tr>
						                
									<tr style="font-size:24px">
						                <td height="50">
						                	<font size="5"><strong>สิทธิการใช้งานในระบบ</strong></font>
						                </td>
						                <td height="50">
						                	Add Edit Read Delete
						                </td>
						            </tr>
						            <tr style="font-size:24px">
						                <td height="50">						                	
						                </td>
						                <td height="50">
						                	<form id="form1" name="form1" method="post" action="change_password.jsp">
												<input type="hidden" id="mode" name="mode" value="admin" /> 
												<input type="hidden" id="system" name="system" value="admin" /> 
												<font size="3" color="#ffffff"><input type="submit" value="เปลี่ยนรหัสผ่าน" class="buttonStyle" style="cursor: pointer;width:200px;"/></font>
												
											</form>
						                </td>
						            </tr>
						     </table>        
						</center>		
										
						<br><br><br>				
				
			<div style="clear: both;"></div>
				
			<div id="footer"></div>
			
		</div>		
			<div style="clear: both;"></div>		
   </div>
</body>
</html>